# Use this R-Chunk to import all your datasets!
world_path <- "http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip"
df <- tempfile();
uf <- tempfile()
download(world_path, df, mode = "wb")
unzip(df, exdir = uf)
world <- read_sf(uf)
file_delete(df); dir_delete(uf)
# Total US$ spent per person on health care
gm_ctry_codes <- country_codes
hdpp <- read_csv("healthdpp.csv")
names(hdpp)[1]<-"country"
hdpp <- left_join(gm_ctry_codes,hdpp, by = "country")
hdpp_geo <- world %>%
select("UN") %>%
left_join(hdpp, by = c("UN"="iso_num")) %>%
filter(!is.na(country)) %>%
mutate_at(4:19, funs(round(., 2)))
# Life Expectancy in years
lifexp <- read_csv("lifexp.csv")
names(lifexp)[1]<-"country"
lifexp <- left_join(gm_ctry_codes,lifexp, by = "country") %>%
select(1:3,199:214)
life_geo <- world %>%
select("UN") %>%
left_join(lifexp, by = c("UN"="iso_num")) %>%
filter(!is.na(country))
hdpp_tidy <- hdpp %>%
select(-(2:3)) %>%
gather(Year, hdpp, -country)
life_tidy <- lifexp %>%
select(-(2:3)) %>%
gather(Year, lifexp, -country)
Biggie <-left_join(hdpp_tidy,life_tidy, by = c("country","Year"))
Biggie$Year <- as.integer(Biggie$Year)
wdt <- read_csv("wdt.csv")
Biggie <- left_join(wdt,Biggie, by = c("Country" = "country" , "Year" = "Year"))
The United States is trying to outspend every other nation on the planet with health care. We spend almost 18% of our GDP on healthcare.
According to a pbs.org study, in the United States:
There is no doubt that the quality of medical care has an influence on life expectancy but it is interesting to look at the amount money the United States is spending and the results that we see in life expectancy compared to other nations.
#leaflet(data = world) %>%
# setView(lng = -10, lat = 20, zoom =2) %>%
#addProviderTiles(providers$Esri.WorldImagery) %>%
#addPolygons(data = world) %>%
#addPolygons(data = us)
bins <- c(0,100,200,400,800,1600,3200,6400,Inf)
leaflet(data =hdpp_geo) %>%
setView(lng = 0, lat = 20, zoom =2) %>%
addProviderTiles(providers$Esri.WorldImagery) %>%
addPolygons(color = "black", weight = 2, fillColor = "none") %>%
# other color options: "RdYlBu"
addPolygons(fillColor = ~colorBin("RdYlBu", c(0,8000), bins = bins)(`1995`),
fillOpacity = .75, color = "black", weight = 1, group = "1995",
popup = paste0("<strong>Country: </strong>", hdpp_geo$country,
"<br><strong>Ave Per Person: $</strong>", hdpp_geo$`1995`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(0,8000), bins = bins)(`1999`),
fillOpacity = .75, color = "black", weight = 1, group = "1999",
popup = paste0("<strong>Country: </strong>", hdpp_geo$country,
"<br><strong>Ave Per Person: $</strong>", hdpp_geo$`1999`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(0,8000), bins = bins)(`2003`),
fillOpacity = .75, color = "black", weight = 1, group = "2003",
popup = paste0("<strong>Country: </strong>", hdpp_geo$country,
"<br><strong>Ave Per Person: $</strong>", hdpp_geo$`2003`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(0,8000), bins = bins)(`2007`),
fillOpacity = .75, color = "black", weight = 1, group = "2007",
popup = paste0("<strong>Country: </strong>", hdpp_geo$country,
"<br><strong>Ave Per Person: $</strong>", hdpp_geo$`2007`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(0,8000), bins = bins)(`2010`),
fillOpacity = .75, color = "black", weight = 1, group = "2010",
popup = paste0("<strong>Country: </strong>", hdpp_geo$country,
"<br><strong>Ave Per Person: $</strong>", hdpp_geo$`2010`)) %>%
addLayersControl(baseGroups = c("1995","1999","2003","2007","2010","None"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend("bottomleft", pal = colorBin("RdYlBu",c(0,8000), bins = bins), values =
c(0,8000),title = "$US ave per Person",opacity = 1)
bins <- c(0,50,66,74,78,80,Inf)
leaflet(data =life_geo) %>%
setView(lng = 0, lat = 20, zoom =2) %>%
addProviderTiles(providers$Esri.WorldImagery) %>%
addPolygons(color = "black", weight = 2, fillColor = "none") %>%
# other color options: "RdYlBu"
addPolygons(fillColor = ~colorBin("RdYlBu", c(10,90), bins = bins)(`1995`),
fillOpacity = .75, color = "black", weight = 1, group = "1995",
popup = paste0("<strong>Country: </strong>", life_geo$country,
"<br><strong>Life Exp: </strong>", life_geo$`1995`))%>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(10,90), bins = bins)(`1999`),
fillOpacity = .75, color = "black", weight = 1, group = "1999",
popup = paste0("<strong>Country: </strong>", life_geo$country,
"<br><strong>Life Exp: </strong>", life_geo$`1999`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(10,90), bins = bins)(`2003`),
fillOpacity = .75, color = "black", weight = 1, group = "2003",
popup = paste0("<strong>Country: </strong>", life_geo$country,
"<br><strong>Life Exp: </strong>", life_geo$`2003`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(10,90), bins = bins)(`2007`),
fillOpacity = .75, color = "black", weight = 1, group = "2007",
popup = paste0("<strong>Country: </strong>", life_geo$country,
"<br><strong>Life Exp: </strong>", life_geo$`2007`)) %>%
addPolygons(fillColor = ~colorBin("RdYlBu", c(10,90), bins = bins)(`2010`),
fillOpacity = .75, color = "black", weight = 1, group = "2010",
popup = paste0("<strong>Country: </strong>", life_geo$country,
"<br><strong>Life Exp: </strong>", life_geo$`2010`)) %>%
addLayersControl(baseGroups = c("1995","1999","2003","2007","2010","None"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend("bottomleft", pal = colorBin("RdYlBu",c(10,90), bins = bins), values =
c(10,90),title = "ave life exp",opacity = 1)
Biggie %>%
plot_ly(x = ~hdpp, y = ~lifexp,
size = ~Population, color = ~Region, frame = ~Year, text = ~Country,
hoverinfo = "text",type = 'scatter',mode = 'markers') %>%
layout(xaxis = list(title = "Health Expenatures: Average Per Person"), yaxis = list(title = "Life Expectancy"))
I am certain that there are a myriad of variables to consider when we look at the relationship between healthcare expenditures and life expectancy. However, it is easy to see that the United States is an extreme outlier in this model and not in a good way. I am a little embarrassed to see where we sit in comparison to the rest of the world.
Understand, the costs associated with individuals and their treatments are heavily skewed right; most individuals have little to no annual costs; while a few have exorbitant costs.
Since spending more on healthcare has little affect on life expectancy, it seems reasonable to try to decrease healthcare spending in the United States.
There are two ways to decrease overall healthcare costs:
Neither of these options are very popular.